<!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
<script src="__TMPL__/public/assets/simpleboot3/bootstrap/js/bootstrap.min.js"></script>
<script src="__STATIC__/js/frontend.js"></script>
	<script>
	$(function(){
		$("#main-menu li.dropdown").hover(function(){
			$(this).addClass("open");
		},function(){
			$(this).removeClass("open");
		});
		
		$("#main-menu a").each(function() {
			if ($(this)[0].href == String(window.location)) {
				$(this).parentsUntil("#main-menu>ul>li").addClass("active");
			}
		});
		
		$.post("{:url('user/index/isLogin')}",{},function(data){
		    console.log(data);
			if(data.code==1){
				if(data.data.user.avatar){
				}
				$(".xy_user-nickname a").text(data.data.user.user_nickname?data.data.user.user_nickname:data.data.user.user_login);
				$("#xy_user_login").show();
                $("#xy_user_offline").hide();

			}

			if(data.code==0){
                $("#xy_user_login").hide();
				$("#xy_user_offline").show();
			}

		});

        ;(function($){
			$.fn.totop=function(opt){
				var scrolling=false;
				return this.each(function(){
					var $this=$(this);
					$(window).scroll(function(){
						if(!scrolling){
							var sd=$(window).scrollTop();
							if(sd>100){
								$this.fadeIn();
							}else{
								$this.fadeOut();
							}
						}
					});
					
					$this.click(function(){
						scrolling=true;
						$('html, body').animate({
							scrollTop : 0
						}, 500,function(){
							scrolling=false;
							$this.fadeOut();
						});
					});
				});
			};
		})(jQuery); 
		
		$("#backtotop").totop();

	});
    $(document).ready(function () {
        $("#xy_user_login").mouseenter(function () {
            $("#xy_user2").show();
        });
        $("body").click(function () {
            $("#xy_user2").hide();
        });
    });

    var nav = $("header");
    var win = $(window);
    var sc = $(document);
    win.scroll(function () {
        var nav_height;
        if(sc.scrollTop() < 40){
            nav_height = 100 - sc.scrollTop();
        }
        if (sc.scrollTop()>=0){
            nav.addClass("fixednav");
            $(".div_nav").css('height','100px');
           // console.log(nav_height);
            //nav.css('height',nav_height+'px');
        }else{
            nav.removeClass("fixednav");
            $(".div_nav").css('height','0px');
        }
    });
	</script>

